package com.liyuhang.controller;

import com.liyuhang.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

@Controller
public class UserController {
    @Autowired
    private UserService userService;
    @SuppressWarnings("Duplicates")
    @RequestMapping("/userLogin")
    public String login(final HttpServletRequest request){
        String username=request.getParameter("username");
        String password=request.getParameter("password");
        request.getSession().setAttribute("username",username);
        request.getSession().setAttribute("password",password);
        return userService.login(username,password)==true?"success":"error";
    }
}
